package com.lbd99.data.lbd.service;

import com.lbd99.data.lbd.dao.TInvitationMapper;
import com.lbd99.data.lbd.dao.TMessageMapper;
import com.lbd99.data.lbd.dao.TMessageTempMapper;
import com.lbd99.data.lbd.dao.TUserMapper;
import com.lbd99.data.lbd.vo.TInvitation;
import com.lbd99.data.lbd.vo.TMessage;
import com.lbd99.data.lbd.vo.TMessageTemp;
import com.lbd99.data.lbd.vo.TUser;
import com.lbd99.data.utils.RandomUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;


@Service
public class TMessageService {

    @Autowired
    TMessageMapper tMessageMapper;

    @Autowired
    TMessageTempMapper tMessageTempMapper;

    @Autowired
    TUserMapper tUserMapper;


    public List<TMessageTemp> selectList(Map<String,Object> map){
        return  tMessageTempMapper.selectList(map);

    }


    public Map<String,Object> insert(String title,String content){

        Map<String,Object> map1=new HashMap<String,Object>();

        List<TUser> list= tUserMapper.selectList(null);

        for (TUser record2 :list) {
            TMessage  record=new TMessage();
            record.setUserId(record2.getId());
            record.setUid(record2.getUid());
            record.setCreateTime(new Date());
            record.setUpdateTime(new Date());
            record.setUpdateBy("-1");
            record.setCreateBy("-1");
            record.setTitle(title);
            record.setContent(content);
            tMessageMapper.insertSelective(record);
        }
        TMessageTemp record3=new TMessageTemp();
        record3.setTitle(title);
        record3.setContent(content);
        record3.setCreateTime(new Date());
        record3.setUpdateTime(new Date());
        record3.setUpdateBy("-1");
        record3.setCreateBy("-1");
        tMessageTempMapper.insertSelective(record3);
        map1.put("isSuc",true);
        map1.put("msg","操作成功");

        return map1;

    }
    
    
    

}
